#### go-kegg 可视化####

library(ggplot2) #主要绘图包
try({
  setwd("/rproject/r-language/lilongyuan2/go-kegg可视化/") 
})
try({
  setwd('/home/r_temp//202483/365578/13/1722663071917/')
})


AA= read.table("/data1/servers/backend/tomcat9-rop-2356/file/userbioinformaticsdata/0/174/shili.txt", sep = "\t", header = T)

# windowsFonts(myFont = windowsFont("Arial")) #字体格式, 环境存在myFont 格式
AA$y 轴 <- sapply(AA$y 轴, function(x) {
  parts <- strsplit(x, "/")[[1]]
  as.numeric(parts[1]) / as.numeric(parts[2])
})


AA$color <- ifelse(AA$ONTOLOGY == "BP", "#1f60a4",
                   ifelse(AA$ONTOLOGY == "CC", "#a40d20", 
                          ifelse(AA$ONTOLOGY == "MF", "#9933FF",
                                 ifelse(AA$ONTOLOGY == "KEGG", "#0000CC","#006633"))))

rainbow(10)
png(filename = 'gokeggpicshow.png',width = 800,height = 800)
ggplot(data = AA, mapping = aes(x=path,y=y 轴)) + # 锁定数据框，X轴Y轴数据
  geom_point(aes(size=10*Count,color=-1*log10(pvalue),shape = factor(ONTOLOGY)))+ #绘制气泡图，shape为圆点形状，如果想统一，可以用shape = 具体数字。
  coord_flip()+ # 将X轴与Y轴调换
  scale_color_gradient(low="#CC3399",high ="#990033")+ #颜色范围
  theme(legend.title = element_text(size = 15, face = 2))+ #图例标题大小
  theme(legend.key.size=unit(1,'cm'))+ #图例标题大小
  theme(legend.text = element_text( size = 12,face = 'bold'))+ #图例图形里文字大小
  labs(x="x 轴",y = "y 轴",title = "图片")+ # X轴、 Y轴 ##title可以修改
  geom_line() +
  theme_bw()+
  theme(plot.background = element_rect(fill = "White"))+ #图片背景颜色设置
  theme(panel.grid.major=element_line(colour="grey")) +
  theme(axis.title.x = element_text(size = 15))+
  theme(axis.text.x = element_text(size = 12, family = "myFont", color = "black", face = "bold"))+
  theme(axis.text.y = element_text(size = 12, family = "myFont", color = AA$color,face = "bold"))+
  theme(plot.title = element_text(size = 15,face = 4, hjust =0.5))

dev.off()
